package cn.hubujyjs.mooc.controller;


import cn.hubujyjs.mooc.common.Result;
import cn.hubujyjs.mooc.entity.SwiperIcon;
import cn.hubujyjs.mooc.service.OssService;
import cn.hubujyjs.mooc.service.SwiperIconService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Huang Jintao
 * @since 2022-11-15
 */
@RestController
@RequestMapping("/api/swiper")
@Api(tags = "首页轮播图接口")
public class SwiperIconController {
    @Autowired
    private SwiperIconService swiperIconService;

    @GetMapping("/getIcon")
    @ApiOperation("获取轮播图列表")
    public Result<List<SwiperIcon>> getIcon(){
        return swiperIconService.listSwiperIcon();
    }
    @PostMapping("/addIcon")
    @ApiOperation("添加轮播图")
    public Result addIcon(@RequestPart("file") MultipartFile file){
        return swiperIconService.addSwiperIcon(file);
    }
    @DeleteMapping("/removeIcon")
    @ApiOperation("删除轮播图")
    public Result removeIcon(Long id){
        return swiperIconService.removeSwiperIcon(id);
    }
}

